package com.hourse.service;


import com.github.pagehelper.PageHelper;
import com.hourse.dao.DgtxDao;
import com.hourse.dao.HouseDao;
import com.hourse.mapper.*;
import com.hourse.pojo.*;
import com.hourse.util.IdWorker;
import com.hourse.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;


import java.util.List;
import java.util.Map;

@Service
public class HouseService {
    @Autowired
    private HouseMapper houseMapper;
    @Autowired
    private DgtxDao dgtxPlacesDao;
    @Autowired
    private HouseHuxingMapper houseHuxingMapper;
    @Autowired
    private HouseKaipanMapper kaipanMapper;
    @Autowired
    private HouseStatusMapper houseStatusMapper;
    @Autowired
    private HouseTeseMapper houseTeseMapper;
    @Autowired
    private HouseWuyeMapper houseWuyeMapper;
    @Autowired
    private HouseZhuangxiuMapper houseZhuangxiuMapper;
    @Autowired
    private HouseDao houseDao;

    @Autowired
    private IdWorker idWorker;

    public List<House> list() {
        return houseMapper.selectByExample(null);
    }


    public void houseAdd(House house) {

        house.setId(idWorker.nextId());

        houseMapper.insert(house);
    }


    public void houseUp(House house) {

        houseMapper.updateByPrimaryKey(house);

    }

    public void houseDelete(Long id) {

        houseMapper.deleteByPrimaryKey(id);

    }

    public Page<House> findAll(Integer page, Integer size) {
       return houseDao.findAll(PageRequest.of(page-1,size));
    }


    public List<DgtxPlaces> shenlist() {
        int i=1;
        Long o=(long)i;
        return dgtxPlacesDao.findByParentId(o);
    }

    public DgtxPlaces shencname(Long id) {
        return dgtxPlacesDao.findById(id).get();
    }

    public List<DgtxPlaces> shicname(Long id) {
        return dgtxPlacesDao.findByParentId(id);
    }

    public List<HouseHuxing> huxinglist() {
        return houseHuxingMapper.selectByExample(null);
    }

    public List<HouseKaipan> kaipanlist() {
        return kaipanMapper.selectByExample(null);
    }

    public List<HouseStatus> statuslist() {
        return houseStatusMapper.selectByExample(null);
    }

    public List<HouseTese> teselist() {
        return houseTeseMapper.selectByExample(null);
    }

    public List<HouseWuye> wuyelist() {
        return houseWuyeMapper.selectByExample(null);
    }

    public List<HouseZhuangxiu> zhuangixulist() {
        return houseZhuangxiuMapper.selectByExample(null);
    }
}
